home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / newlooklib.lha / newlook / addggroupframe.c < prev    next >
C/C++ Source or Header  |  1993-11-07  |  2KB  |  88 lines

  1. /*
  2.  *  ADDGGROUPFRAME.C
  3.  */
  4.  
  5. #include "newlook.h"
  6.  
  7. extern void CopyMem(APTR,APTR,ULONG);
  8. extern LONG IntuiTextLength(struct IntuiText *);
  9.  
  10. BOOL AddGGroupFrame(g, dx,dy, w,h, title)
  11. struct Gadget *g;
  12. SHORT dx,dy, w,h;
  13. STRPTR title;
  14. {
  15.   struct TextFont *tf;
  16.   struct IntuiText *it;
  17.   struct Border *b0, *b1;
  18.   SHORT *xy, tx= dx, ty= dy, cw;
  19.  
  20.   ULONG UserHandle= SetNewLookHandle(PRIVATE_HANDLE);
  21.  
  22.   /* No Border for Gadgets w/ Images */
  23.   if(g && (g->Flags & GADGIMAGE) == NULL)
  24.   {
  25.     if(tf= (struct TextFont *)OpenFont(&Topaz80))
  26.     {
  27.       ty -= tf->tf_Baseline / 2;
  28.       tx += 3 * (cw = tf->tf_XSize);
  29.       CloseFont(tf);
  30.     }
  31.     else ty -= 3, tx += 3 * (cw = 8);  /* `known' topaz 80 dimensions */
  32.  
  33.     if(it= CreateIText(tx,ty,title))
  34.     {
  35.       if(b0= (struct Border *)SmartAllocate(BORDERSIZE))
  36.       {
  37.         if(b1= (struct Border *)SmartAllocate(BORDERSIZE))
  38.         {
  39.           if(xy= (SHORT *)SmartAllocate(GFRAMEXYSIZE))
  40.           {
  41.             --w;
  42.             --h;
  43.  
  44.             xy[0]= 2*cw;    xy[1]= 0;    /* +-+ title +-----------+ */
  45.             xy[2]= 0;       xy[3]= 0;    /* |                     | */
  46.             xy[4]= 0;       xy[5]= h;    /* |                     | */
  47.             xy[6]= w;       xy[7]= h;    /* |                     | */
  48.             xy[8]= w;       xy[9]= 0;    /* +---------------------+ */
  49.  
  50.             xy[10]= 4*cw + IntuiTextLength(it);
  51.             xy[11]= 0;
  52.  
  53.             b0->LeftEdge   = dx;
  54.             b0->TopEdge    = dy;
  55.             b0->FrontPen   = 1L;
  56.             b0->BackPen    = 0L;
  57.             b0->DrawMode   = JAM1;
  58.             b0->Count      = 6;
  59.             b0->XY         = &xy[0];
  60.             b0->NextBorder = (struct Border *)NULL;
  61.  
  62.             CopyMem((APTR)b0, (APTR)b1, BORDERSIZE);
  63.  
  64.             b0->NextBorder= g->GadgetRender;
  65.             g->GadgetRender= b0;
  66.  
  67.             b1->NextBorder= g->SelectRender;
  68.             g->SelectRender= b1;
  69.  
  70.             it->NextText= g->GadgetText;
  71.             g->GadgetText= it;
  72.  
  73.             MakePrivateHandlePublic(UserHandle);
  74.             return TRUE;
  75.           }
  76.         }
  77.       }
  78.     }
  79.   }
  80.  
  81.   if(UserHandle != PRIVATE_HANDLE)
  82.   {
  83.     SmartFreeAll(PRIVATE_HANDLE);
  84.     (void)SetNewLookHandle(UserHandle);
  85.   }
  86.   return FALSE;
  87. }
  88.